package com.market.web.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.market.domain.BaseObject;

public class MarketList<BO extends BaseObject> extends ListDataModel<BO> implements SelectableDataModel<BO> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5967444116985407693L;

	public MarketList(){
		
	}
	
	public MarketList(List<BO> list){
		super(list);
	}

	public BO getRowData(String rowKey) {
		BO rowData = null;		
		Iterator<BO> iterator = this.iterator();		
		while(iterator.hasNext()){
			rowData= iterator.next();
			if(rowData.getId().equals(rowKey)){
				return rowData;
			}
		}
		return null;
	}

	public Object getRowKey(BaseObject rowData) {
		return rowData.getId();
	}

}
